package com.example.csdn.controller;

import com.example.csdn.pojo.Article;
import com.example.csdn.pojo.PageBean;
import com.example.csdn.pojo.Result;
import com.example.csdn.pojo.User;
import com.example.csdn.service.UserManageService;
import org.apache.ibatis.annotations.Delete;
import org.apache.logging.log4j.message.ReusableMessage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/userManage")
public class UserManageController {

    @Autowired
    private UserManageService userManageService;

    @GetMapping
    public Result<PageBean<User>> userManageList(
        Integer pageNum, Integer pageSize,
        @RequestParam(required = false) String identity
    ){
        PageBean<User> pb = userManageService.userManageList(pageNum, pageSize,identity);
        return Result.success(pb);

    }

    @PostMapping
    public Result addUserManager(@RequestBody @Validated User user){
        userManageService.addUserManager(user);
        return Result.success();
    }

    @PutMapping
    public Result updateUserManager(@RequestBody @Validated User user){
        userManageService.updateUserManager(user);
        return Result.success();
    }

    @DeleteMapping
    public Result deleteUserManager(Integer id){
        userManageService.deleteUserManager(id);
        return Result.success();
    }


}
